package com.olt.dao.oltCenter;

import com.olt.domain.oltCenter.ClassStudent;
import com.olt.server.oltCenter.oltStudentServer.dto.StudentOutput;
import org.hibernate.sql.Select;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Collection;
import java.util.List;
import java.util.UUID;

public interface IClassStudent extends JpaRepository<ClassStudent, String> {

    @Query(value = "select " +
            "new  com.olt.server.oltCenter.oltStudentServer.dto.StudentOutput" +
            "(s.name,c.joinTime,s.sex,s.email,s.userId,s.tel)"+
            "from ClassStudent c  left join OltCustom s on s.userId=c.userId where c.classId=?1" +
            " order by  s.userId asc ")
    List<StudentOutput> getStudentByClassIdOrderByUserIdAsc(String classId);

    ClassStudent findByClassIdAndUserId(String classId,Long userId);

    void deleteAllByClassIdAndUserIdIn(String classId, List<Long> userIds);
}
